QuickOPC User's Guide and Reference
Examples - OPC Data Access - Read an item and get a type code
// This example shows how to read a single item and obtains a type code of the received value.

using System;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class ReadItem
    {
        public static void GetTypeCode()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            DAVtq vtq;
            try
            {
                vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random");
            }
            catch (OpcException opcException)
            {
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message);
                return;
            }

            if (!(vtq.Value is null))
            {
                TypeCode typeCode = Type.GetTypeCode(vtq.Value.GetType());

                Console.WriteLine("TypeCode: {0}", typeCode);
            }
        }
    }
}
' This example shows how to read a single item and obtains a type code of the received value.

Imports OpcLabs.EasyOpc.DataAccess
Imports OpcLabs.EasyOpc.OperationModel

Namespace DataAccess._EasyDAClient
    Partial Friend Class ReadItem
        Public Shared Sub GetTypeCode()
            Dim client = New EasyDAClient()

            Dim vtq As DAVtq
            Try
                vtq = client.ReadItem("", "OPCLabs.KitServer.2", "Simulation.Random")
            Catch opcException As OpcException
                Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message)
                Exit Sub
            End Try

            If vtq.Value IsNot Nothing Then
                Dim typeCode As TypeCode = Type.GetTypeCode(vtq.Value.GetType())

                Console.WriteLine("TypeCode: {0}", typeCode)
            End If
        End Sub
    End Class
End Namespace

 

See Also

Conceptual